package com.digitalart.futbol.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.digitalart.futbol.hibernate.ejb.Duenio;
import com.digitalart.futbol.hibernate.service.DuenioService;


@Controller
@RequestMapping(value="/duenio")
public class DuenioController {

	@Autowired
	private DuenioService duenioServ;
	
	@RequestMapping(value = "/add/{nombre}/{cedula}/{telefono}", method = RequestMethod.GET)
	public @ResponseBody Duenio add(@PathVariable("nombre") String nombre,@PathVariable("cedula") String cedula,@PathVariable("telefono") String telefono) {
		
		Duenio duenio = new Duenio();
		duenio.setCedula(cedula);
		duenio.setNombre(nombre);
		duenio.setTelefono(telefono);
		
		duenioServ.createDuenio(duenio);
		
		return duenio;
		
	}
	
	
	@RequestMapping(value = "/getByCedula/{cedula}", method = RequestMethod.GET)
	public @ResponseBody Duenio getByCorreo(@PathVariable("cedula") String cedula) {
		
		Duenio duenio = duenioServ.retriveDuenioByCorreo(cedula);
		
		return duenio;
		
	}
	
}
